<?php
class Clu_Mail_HvnMailer extends Zend_Mail
{
    /**
     * Directory path, where mail templates are located
     *
     * @var string
     */
    protected $templatesDir = '';
 
    /**
     * Constructor for the class, provide directory path where mail templates are saved
     *
     * @param string $templatesDir Directory path, where mail templates are located
     */
    public function __construct($templatesDir = 'languages/mailtemplates')
    {
        $this->templatesDir = $templatesDir;
 
        $mailConfig = Zend_Registry::get('configuration')->mail;
        if ($mailConfig->smtp)
        {
            $transport = new Zend_Mail_Transport_Smtp($mailConfig->host, $mailConfig->smtpconfig->toArray());
        }
        else
        {
            $transport = new Zend_Mail_Transport_Sendmail();
        }
 
        Zend_Mail::setDefaultTransport($transport);
 
    }
 
    public function sendMail($emailAddress, $subject, $body)
    {
        $sitename = Zend_Registry::get('configuration')->general->sitename;
        $mailer = new Zend_Mail('utf-8');
        $mailer->addTo($emailAddress, $subject);
        $mailer->setSubject(sprintf(__('Confirm your registeration in %s'), $sitename));
        $mailer->setBodyHtml($body, 'utf8');
        $mailer->setFrom(Zend_Registry::get('configuration')->mail->from);
        $mailer->send();
    }
    
    public function sendContactMail($emailAddress, $subject, $body)
    {
        $sitename = Zend_Registry::get('configuration')->general->sitename;
        $mailer = new Zend_Mail('utf-8');
        $mailer->setType(Zend_Mime::MULTIPART_RELATED);
        $mailer->addTo($emailAddress, $subject);
        $mailer->setSubject(sprintf(__('Contact %s'), $sitename));
        $mailer->setBodyHtml($body, 'utf8');
        $mailer->setFrom(Zend_Registry::get('configuration')->mail->from);
        
        /*
         * send attach file
         */
//        if (!empty($params['attachFile']) && file_exists($params['attachFile'])){
//	        $at = $mailer->addAttachment(file_get_contents($params['attachFile']));
//	        $at->type        = $params['attachType'];
//	        $at->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
//	        $at->filename    = $params['attachName'];
//    	}
        $mailer->send();
    }
}
?>